package Exercises;/*
 *
 * @author 陈粒
 * @version 创建时间：2021/7/3 11:29
 */

/**
 * 练习题:打印全三角形
 * 需求:接收用户输入的行数,打印对应的全三角形,如图所示:
 */

import java.util.*;

public class PrintTraingle {
    public static void main(String[] args) {
        System.out.println("请输入要打印星星的行数：");
        int input = new Scanner(System.in).nextInt();
        System.out.println("星星如下所示：");
        mathod(input);
    }

    public static void mathod(int input) {
        int a = input;
        int b = 1;
        for (int x = 1; x <= input; x++) {
            for (int i = 1; i <= (a - 1); i++) {
                System.out.print(" ");
            }
            for (int j = 1; j <= ((2 * b) - 1); j++) {
                System.out.print("*");
            }
            a--;
            b++;
            System.out.println();
        }
    }
}
